import requeset from '@/utils/request'
import { useUserStore } from '@/stores/counter'
//注册接口
export const userRegisterService = ({
  username,
  password,
  repassword
}) =>
  requeset.post('/api/reg', {
    username,
    password,
    repassword
  })
//登录接口
export const userLoginService = ({
  username,
  password
}) =>
  requeset.post('/api/login', {
    username,
    password
  })
export const userGetUserInfoService =
  async () => {
    const userStore = useUserStore()
    const { data } = await requeset.get(
      '/my/userinfo'
    )
    userStore.setUserInof(data.data)
  }
//修改用户信息接口
export const userUpInfoService = (data) =>
  requeset.put('/my/userinfo', data)
//更新用户头像
export const userUpdataImgService = (avatar) =>
  requeset.patch('/my/update/avatar', { avatar })
//重置用户密码
export const userUpdataPwdService = (data) =>
  requeset.patch('/my/updatepwd', { ...data })
